/*
 * Created by JFormDesigner on Sun Jun 26 14:38:39 CST 2022
 */

package com.keshe.jsp;

import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.GroupLayout;
import com.keshe.service.RoomContorller;

/**
 * @author 1
 */
public class AddRoom extends JFrame {
    public AddRoom() {
        initComponents();
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        ResourceBundle bundle = ResourceBundle.getBundle("com.keshe.jsp.form");
        action1 = new addRoom();
        action2 = new dispose();
        label7 = new JLabel();
        panel1 = new JPanel();
        label8 = new JLabel();
        textField4 = new JTextField();
        label9 = new JLabel();
        textField5 = new JTextField();
        label10 = new JLabel();
        comboBox2 = new JComboBox<>();
        label11 = new JLabel();
        textField6 = new JTextField();
        label12 = new JLabel();
        radioButton2 = new JRadioButton();
        radioButton3 = new JRadioButton();
        label13 = new JLabel();
        comboBox3 = new JComboBox<>();
        label14 = new JLabel();
        textField7 = new JTextField();
        button1 = new JButton();
        button2 = new JButton();
        label1 = new JLabel();
        textField1 = new JTextField();

        //======== this ========
        setIconImage(new ImageIcon(getClass().getResource("/images/\u9152\u5e97 (1).png")).getImage());
        setTitle("\u6dfb\u52a0\u5ba2\u623f\u4fe1\u606f");
        Container contentPane = getContentPane();

        //---- label7 ----
        label7.setText(bundle.getString("label7.text"));
        label7.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 30));
        label7.setHorizontalAlignment(SwingConstants.CENTER);
        label7.setIcon(new ImageIcon(getClass().getResource("/images/\u623f\u95f4 (1).png")));

        //======== panel1 ========
        {

            //---- label8 ----
            label8.setText(bundle.getString("label8.text"));
            label8.setIcon(new ImageIcon(getClass().getResource("/images/\u7f16\u53f7.png")));

            //---- label9 ----
            label9.setText(bundle.getString("label9.text"));
            label9.setIcon(new ImageIcon(getClass().getResource("/images/\u5165\u5e93\u7c7b\u578b.png")));

            //---- label10 ----
            label10.setText(bundle.getString("label10.text"));
            label10.setIcon(new ImageIcon(getClass().getResource("/images/\u4f4d\u7f6e.png")));

            //---- comboBox2 ----
            comboBox2.setModel(new DefaultComboBoxModel<>(new String[] {
                "--\u8bf7\u9009\u62e9--",
                "1\u697c",
                "2\u697c",
                "3\u697c"
            }));

            //---- label11 ----
            label11.setText(bundle.getString("label11.text"));
            label11.setIcon(new ImageIcon(getClass().getResource("/images/\u4ef7\u683c.png")));

            //---- label12 ----
            label12.setText(bundle.getString("label12.text"));
            label12.setIcon(new ImageIcon(getClass().getResource("/images/\u7b49\u5f85sap\u7a7a\u95f2.png")));

            //---- radioButton2 ----
            radioButton2.setText(bundle.getString("radioButton2.text"));

            //---- radioButton3 ----
            radioButton3.setText(bundle.getString("radioButton3.text"));

            //---- label13 ----
            label13.setText(bundle.getString("label13.text"));
            label13.setIcon(new ImageIcon(getClass().getResource("/images/\u4ef7\u683c.png")));

            //---- comboBox3 ----
            comboBox3.setModel(new DefaultComboBoxModel<>(new String[] {
                "--\u8bf7\u9009\u62e9--",
                "\u5df2\u6e05\u6d01",
                "\u672a\u6e05\u6d01"
            }));

            //---- label14 ----
            label14.setText(bundle.getString("label14.text"));
            label14.setIcon(new ImageIcon(getClass().getResource("/images/\u63cf\u8ff0.png")));

            //---- button1 ----
            button1.setAction(action1);

            //---- button2 ----
            button2.setAction(action2);
            button2.setText("\u8fd4\u56de");

            //---- label1 ----
            label1.setText(bundle.getString("label1.text_18"));
            label1.setIcon(new ImageIcon(getClass().getResource("/images/\u4eba\u5747\u4f4f\u623f\u9762\u79ef.png")));

            GroupLayout panel1Layout = new GroupLayout(panel1);
            panel1.setLayout(panel1Layout);
            panel1Layout.setHorizontalGroup(
                panel1Layout.createParallelGroup()
                    .addGroup(panel1Layout.createSequentialGroup()
                        .addGap(89, 89, 89)
                        .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                            .addComponent(textField7)
                            .addGroup(panel1Layout.createSequentialGroup()
                                .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                                    .addGroup(panel1Layout.createSequentialGroup()
                                        .addGroup(panel1Layout.createParallelGroup()
                                            .addComponent(label8)
                                            .addComponent(label10))
                                        .addGap(18, 18, 18)
                                        .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                                            .addComponent(textField4, GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE)
                                            .addComponent(comboBox2, GroupLayout.DEFAULT_SIZE, 1, Short.MAX_VALUE)))
                                    .addGroup(panel1Layout.createSequentialGroup()
                                        .addGroup(panel1Layout.createParallelGroup()
                                            .addComponent(label12)
                                            .addComponent(label1))
                                        .addGap(18, 18, 18)
                                        .addGroup(panel1Layout.createParallelGroup()
                                            .addGroup(panel1Layout.createSequentialGroup()
                                                .addComponent(radioButton2)
                                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
                                                .addComponent(radioButton3))
                                            .addComponent(textField1))))
                                .addGap(84, 84, 84)
                                .addGroup(panel1Layout.createParallelGroup()
                                    .addComponent(label9)
                                    .addComponent(label11)
                                    .addComponent(label13))
                                .addGap(18, 18, 18)
                                .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                                    .addComponent(comboBox3, GroupLayout.DEFAULT_SIZE, 1, Short.MAX_VALUE)
                                    .addComponent(textField6, GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE)
                                    .addComponent(textField5)))
                            .addComponent(label14))
                        .addContainerGap(67, Short.MAX_VALUE))
                    .addGroup(panel1Layout.createSequentialGroup()
                        .addGap(163, 163, 163)
                        .addComponent(button1)
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 164, Short.MAX_VALUE)
                        .addComponent(button2)
                        .addGap(130, 130, 130))
            );
            panel1Layout.setVerticalGroup(
                panel1Layout.createParallelGroup()
                    .addGroup(panel1Layout.createSequentialGroup()
                        .addGap(37, 37, 37)
                        .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(label8)
                            .addComponent(textField4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addComponent(label9)
                            .addComponent(textField5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(label10)
                            .addComponent(comboBox2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addComponent(label11)
                            .addComponent(textField6, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(label12)
                            .addComponent(radioButton3)
                            .addComponent(radioButton2)
                            .addComponent(label13)
                            .addComponent(comboBox3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                        .addGap(16, 16, 16)
                        .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(label1)
                            .addComponent(textField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(label14)
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textField7, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(button1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(button2))
                        .addContainerGap(7, Short.MAX_VALUE))
            );
        }

        GroupLayout contentPaneLayout = new GroupLayout(contentPane);
        contentPane.setLayout(contentPaneLayout);
        contentPaneLayout.setHorizontalGroup(
            contentPaneLayout.createParallelGroup()
                .addGroup(contentPaneLayout.createParallelGroup()
                    .addGroup(contentPaneLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addGroup(contentPaneLayout.createParallelGroup()
                            .addComponent(label7, GroupLayout.PREFERRED_SIZE, 606, GroupLayout.PREFERRED_SIZE)
                            .addComponent(panel1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
                .addGap(0, 613, Short.MAX_VALUE)
        );
        contentPaneLayout.setVerticalGroup(
            contentPaneLayout.createParallelGroup()
                .addGroup(contentPaneLayout.createParallelGroup()
                    .addGroup(contentPaneLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(label7, GroupLayout.PREFERRED_SIZE, 74, GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(panel1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 29, Short.MAX_VALUE)))
                .addGap(0, 428, Short.MAX_VALUE)
        );
        pack();
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    private addRoom action1;
    private dispose action2;
    private JLabel label7;
    private JPanel panel1;
    private JLabel label8;
    private JTextField textField4;
    private JLabel label9;
    private JTextField textField5;
    private JLabel label10;
    private JComboBox<String> comboBox2;
    private JLabel label11;
    private JTextField textField6;
    private JLabel label12;
    private JRadioButton radioButton2;
    private JRadioButton radioButton3;
    private JLabel label13;
    private JComboBox<String> comboBox3;
    private JLabel label14;
    private JTextField textField7;
    private JButton button1;
    private JButton button2;
    private JLabel label1;
    private JTextField textField1;
    // JFormDesigner - End of variables declaration  //GEN-END:variables

    private class addRoom extends AbstractAction {
        private addRoom() {
            // JFormDesigner - Action initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
            ResourceBundle bundle = ResourceBundle.getBundle("com.keshe.jsp.form");

            putValue(NAME, bundle.getString("action1.Name_11"));
            // JFormDesigner - End of action initialization  //GEN-END:initComponents
        }

        public void actionPerformed(ActionEvent e) {
            // TODO add your code here
            RoomContorller rc=new RoomContorller();
            int flag=rc.addRoom(textField4.getText(),textField5.getText(),String.valueOf(comboBox2.getSelectedItem()) ,Integer.parseInt(textField6.getText()),textField1.getText(),radioButton2.getText(),String.valueOf(comboBox3.getSelectedItem()),textField7.getText() );
            if(flag==1){
                JOptionPane.showMessageDialog(null,"添加成功");
                dispose();
                new Index().setVisible(true);
            }else if(flag==-1){
                JOptionPane.showMessageDialog(null,"请完善信息再提交修改");
            }else{
                JOptionPane.showMessageDialog(null,"添加失败");
            }
        }
    }

    private class dispose extends AbstractAction {
        private dispose() {
            // JFormDesigner - Action initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
            ResourceBundle bundle = ResourceBundle.getBundle("com.keshe.jsp.form");

            putValue(NAME, bundle.getString("action2.Name_5"));
            // JFormDesigner - End of action initialization  //GEN-END:initComponents
        }

        public void actionPerformed(ActionEvent e) {
            // TODO add your code here
            dispose();
            new Index().setVisible(true);
        }
    }
}
